package main

import (
	"fmt"
	"time"
)

func tests1() {
	ch1 := make(chan int, 1)
	ch1 <- 1
	// ch1 <- 1 //  block

	go func() {
		select {
		case val1 := <-ch1:
			fmt.Println("ch1", val1)
		}
	}()

	// ch1 <- 1  // block
	ch1 <- 1
}

func tests2() {
	ch1 := make(chan int, 1)
	ch1 <- 1
	// ch1 <- 1 //  block

	go func() {
		for val1 := range ch1 {
			fmt.Println("ch1", val1)
		}
	}()

	ch1 <- 1
	ch1 <- 1
}

func tests3() {
	ch1 := make(chan int, 0)
	// ch1 <- 1 // block
	// ch1 <- 1 //  block

	go func() {
		for val1 := range ch1 {
			fmt.Println("ch1", val1)
		}
	}()

	ch1 <- 1
	ch1 <- 1
}
func main() {
	tests3()
	// tests2()
	// tests1()

	time.Sleep(1 * time.Second)
}
